* ECERS/ITERS ANALYSIS
***********************
***********************

clear all
set more off
capture log close

set maxvar 10000

	
 if c(username) == "alison_a" {
        global ROOT "C:\Users\alison_a\Dropbox\HI_shared (1)\"
		global ROOT1 "C:\Users\alison_a\Dropbox\HI_shared (1)\"
    }
			
global output 				"$ROOT/endline report/draft 2"
global do 					"$ROOT/do-files"

global data_constructed 	"C:\Users\alison_a\Dropbox\HI_shared (1)\endline report\FINAL\DATA"

global rw 					"$ROOT/data/RW/T-value distributions"
		
*run programme to draw tables
do "$do/stata programs for drawing tables/programs for endline tables, standardisations etc"

********************************************************************************************************************************************************	
* ANALYSIS TYPE 1: CLASS LEVEL AT BL & FU 
********************************************************************************************************************************************************
*1.1: ECERS ONLY 
use "$data_constructed/ECERS_ITERS_clean", clear
preserve
keep if ecers==1

drop *m14* *m13*
reshape wide  espac_muebl* rut_cuis* leng_razo* actividades* interaccion* estruc_prog* padres_pers* infraestructura* procesos*  /*
*/ ecers_f* itec_f*_z total classname ecers NumChildren teach_stu_ratio, i(ll_aulaclass) j(wave)
*drop non-panel
drop if classname0=="" | classname1==""
count/*76*/


global qual0  itec_f1_z0 itec_f2_z0 itec_f3_z0 itec_f4_z0 itec_f5_z0 itec_f6_z0 itec_f7_z0	
label var itec_f1_z1 "Space+furnishings"
label var itec_f2_z1 "Personal care"
label var itec_f3_z1 "Language+reasoning"
label var itec_f4_z1 "Activities"
label var itec_f5_z1 "Interaction"
label var itec_f6_z1 "Program structure"
label var itec_f7_z1 "Parents+staff"


**
tab dane, gen(dane_)

myttests  itec_f1_z1 itec_f2_z1 itec_f3_z1 itec_f4_z1 itec_f5_z1 itec_f6_z1 itec_f7_z1, cluster(ll_inst) itt2(itt2) itt3(itt3) controls($qual0 NumChildren0 teach_stu_ratio0) 
table_std_2s, filename(ecers_fz) 

	
restore

	
* RUN AT CLASS LEVEL (FOR PANEL CLASSES = 115 CLASSES)
****************************************************************************
preserve
drop *m14* *m13*

reshape wide espac_muebl* rut_cuis* leng_razo* actividades* interaccion* estruc_prog* padres_pers* infraestructura* procesos* /*
*/ ecers_f* iters_f* itec_f*_z total classname ecers NumChildren teach_stu_ratio, i(ll_aulaclass) j(wave)
*drop non-panel
drop if classname0=="" | classname1==""
count /*115*/

**
tab dane, gen(dane_)
*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

	
global qual0  itec_f1_z0 itec_f2_z0 itec_f3_z0 itec_f4_z0 itec_f5_z0 itec_f6_z0 itec_f7_z0	
label var itec_f1_z1 "Space+furnishings"
label var itec_f2_z1 "Personal care"
label var itec_f3_z1 "Lang+liter/speak+list"
label var itec_f4_z1 "Activities"
label var itec_f5_z1 "Interaction"
label var itec_f6_z1 "Program structure"
label var itec_f7_z1 "Parents+staff"

	
myttests itec_f1_z1 itec_f2_z1 itec_f3_z1 itec_f4_z1 itec_f5_z1 itec_f6_z1 itec_f7_z1, itt2(itt2) itt3(itt3) controls($qual0 NumChildren0 teach_stu_ratio0 ) 
table_std_2s, filename(itec_fz)

 sum itec_f1_z1 itec_f2_z1 itec_f3_z1 itec_f4_z1 itec_f5_z1 itec_f6_z1 itec_f7_z1
restore	


	
************************************************************************************************************
* CLASS LEVEL MEASURES AT FU; CENTER LEVEL MEANS AS BL CONTROLS
************************************************************************************************************
* ECERS-R/ITERS-R scores for all panel centers
************************************************************************************************************
*generate baseline means - 1 per centre (ecers with iters)
preserve
keep if wave==0
collapse (mean) procesos* infraestructura* espac_muebl* rut_cuis* leng_razo* actividades* interaccion* estruc_prog* padres_pers* itec_f*  NumChildren teach_stu_ratio, by(ll_inst)
foreach x of varlist procesos* infraestructura* espac_muebl* rut_cuis* leng_razo* actividades* interaccion* estruc_prog* padres_pers* itec_f*  NumChildren teach_stu_ratio{
	rename `x' `x'_0
	}
tempfile temp
save `temp'
restore

*merge with centre level follow-up measures
preserve
keep if wave==1
merge m:1 ll_inst using `temp'
keep if _m==3
drop _m
keep if wave==1

/*
*UNSTANDARDISED
local replace replace
foreach x of varlist espac_muebl rut_cuis leng_razo actividades interaccion estruc_prog padres_pers {
	regress `x' treat* `x'_0 if ecers==1, cluster(inst)
	outreg2 using "$output/ECERS_ITERS/ECERS.xls", `replace' 
	local replace 
	}
*/

global qual0 itec_f1_z_0 itec_f2_z_0 itec_f3_z_0 itec_f4_z_0 itec_f5_z_0 itec_f6_z_0 itec_f7_z_0

*!!!!!!!!!!!!!!!!!!!!!!!!!!!!
tab dane, gen(dane_)
myttests itec_f1_z itec_f2_z itec_f3_z itec_f4_z itec_f5_z itec_f6_z itec_f7_z, cluster(ll_inst) itt2(itt2) itt3(itt3) controls($qual0 NumChildren_0 teach_stu_ratio_0) 
table_std_2s, filename(itec_centre_fz)
	
restore


